/**
 * 用户相关类型定义
 */

/**
 * 用户状态枚举
 */
export enum UserStatus {
  ACTIVE = 'active',
  INACTIVE = 'inactive',
  PENDING = 'pending',
  SUSPENDED = 'suspended'
}

/**
 * 用户基础信息
 */
export interface BaseUser {
  id: string;
  username?: string;
  email?: string;
  phone_number?: string;
  nickname?: string;
  avatar_url?: string;
  status: UserStatus;
  created_at: Date;
  updated_at: Date;
}

/**
 * 用户详细信息（包含敏感信息）
 */
export interface User extends BaseUser {
  openid?: string;
  session_key?: string;
  unionid?: string;
  publishing_credits: number;
  last_login_at?: Date;
  login_count: number;
}

/**
 * 用户公开信息（用于API返回）
 */
export interface PublicUser extends Omit<BaseUser, 'email' | 'phone_number'> {
  publishing_credits?: number;
  last_login_at?: Date;
}

/**
 * 用户登录参数
 */
export interface LoginParams {
  code?: string; // 微信登录code
  username?: string;
  password?: string;
  loginType: 'wechat' | 'account';
}

/**
 * 用户注册参数
 */
export interface RegisterParams {
  username: string;
  password: string;
  email?: string;
  phone_number?: string;
  nickname?: string;
}

/**
 * 用户更新参数
 */
export interface UpdateUserParams {
  nickname?: string;
  avatar_url?: string;
  phone_number?: string;
  email?: string;
}

/**
 * JWT Token载荷
 */
export interface UserTokenPayload {
  user_id: string;
  username?: string;
  status: UserStatus;
  iat?: number;
  exp?: number;
}